#ifndef AES_H
#define AES_H
#ifdef __cplusplus
extern "C" {
#endif

#ifndef NULL
#define NULL (void *)0
#endif

#include "stdint.h"

#define SUCCESS 0
#define PARM_ERROR 1
#define NOT_INIT_KEY 2

#define BLOCK_SIZE 16

extern const uint8_t S_BOX[256];

typedef struct
{
	uint32_t nr;		// rounds
	uint32_t *rk;		// round_key
	uint32_t buf[68];	// store round_keys, each block is 4 bytes
} aes_context;

int aes_set_key(aes_context *ctx, const uint8_t *key, uint32_t key_bit);

int aes_encrypt_block(aes_context *ctx, uint8_t cipher_text[16], const uint8_t text[16]);
int aes_decrypt_block(aes_context *ctx, uint8_t text[16], const uint8_t cipher_text[16]);


extern const uint8_t S_BOX[256];
extern const uint8_t INV_S_BOX[256];
extern const uint8_t MIX[4][4];
extern const uint8_t INV_MIX[4][4];
extern const uint32_t RCON[10];

int aes_test();

#ifdef __cplusplus
}
#endif
#endif
